using System;
using System.Data;
using Provausio.Common.Objects;
using Provausio.Common.Utility.Extensions;
using TrainingManagement.api.Models.BusinessObjects;

namespace TrainingManagement.api.Models.Data.Readers
{
    public class TrainingRecordDataReader : BusinessOperation<IDataRecord, TrainingRecord>
    {
        public override TrainingRecord Run(IDataRecord input)
        {
            var record = new TrainingRecord
                {
                    TrainingRecordId = input["TrainingRecordID"].DbTo<int>(),
                    EmployeeId = input["EmployeeID"].DbTo<int>(),
                    DueDate = input["DueDate"].DbTo<DateTime>(),
                    CompletedDate = input["CompletedDate"].DbTo<DateTime?>(),
                    SkillId = input["SkillID"].DbTo<int>()
                };
            return record;
        }
    }
}